package com.wn.controller;


import com.common.entity.Rsp;
import com.wn.service.SensitiveWordService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Set;

@RequestMapping("word")
@RestController
public class SensitiveWordController {

    @Resource
    private SensitiveWordService sensitiveWordService;


    /**
     * 敏感词过滤
     *
     * @param text
     * @return
     */

    @PostMapping("filter")
    public Rsp sensitiveWordFiltering(@RequestBody String text)
    {
        System.out.println(text);
        try
        {
            Set<String> set = sensitiveWordService.sensitiveWordFiltering(text);
            return Rsp.success(set);
        }
        catch (Exception e)
        {
//            throw new RoxException("过滤敏感词出错，请联系维护人员");
            e.printStackTrace();
            return Rsp.fail();
        }
    }
}
